<?php
/* @var $this ReservationController */
/* @var $model Reservation */
/* @var $form CActiveForm */

// Loads external javascript file for total cost computation.
Yii::app()->clientScript->registerScriptFile(Yii::app()->baseUrl . '/js/reservation.js');
?>

<div class="form">

<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'reservation-form',
	'enableAjaxValidation'=>false,
)); ?>

	<p class="note">Fields with <span class="required">*</span> are required.</p>

	<?php echo $form->errorSummary($model); ?>

	
	<div class="row">
		<?php echo $form->labelEx($model,'reserve_reservationdate_from'); ?>
		<?php echo CHtml::activeTextField($model,'reserve_reservationdate_from',array("id"=>"reserve_reservationdate_from",
				'onChange'=>'javascript:computeCost()',
				//'readonly'=>true,
					)); ?>
		&nbsp;<b><i>(Click the box to choose a specific start date.)</b></i>
		<?php $this->widget('application.extensions.calendar.SCalendar',
        array(
        'inputField'=>'reserve_reservationdate_from',
        'ifFormat'=>'%Y-%m-%d',
		));
		?>
	</div>

	
	<div class="row">
		<?php echo $form->labelEx($model,'reserve_reservationdate_to'); ?>
		<?php echo CHtml::activeTextField($model,'reserve_reservationdate_to',array("id"=>"reserve_reservationdate_to",
				'onChange'=>'javascript:computeCost()',
				//'readonly'=>true,
		)); ?>
		&nbsp;<b><i>(Click the box to choose a specific end date.)</b></i>
		<?php $this->widget('application.extensions.calendar.SCalendar',
        array(
        'inputField'=>'reserve_reservationdate_to',
        'ifFormat'=>'%Y-%m-%d',
		));
		?>
	</div>
	<h6>*max of 10 persons</h6>
	<div class="row">
		<?php echo $form->labelEx($model,'reserve_noofadults'); ?>
		<?php echo $form->dropDownList($model,'reserve_noofadults',
			array('1'=>'1', '2'=>'2', '3'=>'3', '4'=>'4', '5'=>'5', '6'=>'6','7'=>'7', '8'=>'8'),
			array('id'=>'adults','prompt'=>'Select No. of Adults',
			/*'ajax' => array(
								'type'=>'POST', //request type
								'data'=>array('reserve_noofadults'=>'js:this.value'),
								//'update'=>'#reserve_noofchildren',
								'update'=>'#'.CHtml::activeId($model, 'reserve_noofchildren'), //selector to update
								'url'=>CController::createUrl('reservation/person'), //url to call.
								),*/
			'onChange'=>'javascript:computeChild()',					
			) ); ?>
			&nbsp;<b><i>(Select No. of Adults first)</b></i>
		<?php echo $form->error($model,'reserve_noofadults'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'reserve_noofchildren'); ?>
		<?php echo $form->dropDownList($model,'reserve_noofchildren',array(),array('prompt'=>'Select No. of Child','id'=>'children') ); ?>
		<?php echo $form->error($model,'reserve_noofchildren'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'unit_id'); ?>
		<?php echo $form->dropDownList($model,'unit_id', CHtml::listData(
		Unit::model()->findAll(),'id','unit_no'), array('prompt' => 'Select Unit', 'id'=>'unitid', 
			'onChange'=>'javascript:computeCost()'
		)); ?>
		<?php echo $form->error($model,'unit_id'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'account_id'); ?>
		<?php if (Yii::app()->user->name!='admin'): ?>
			<?php echo $form->hiddenField($model,'account_id',array('value'=>Yii::app()->user->id)); ?>
			<?php echo $form->textField($model,'account_id',array('value'=>Yii::app()->user->name,'disabled'=>'disabled')); ?>
		<?php endif; ?>
		<?php if (Yii::app()->user->name=='admin'): ?>
			<?php echo $form->dropDownList($model,'account_id', CHtml::listData(
			Account::model()->findAll(), 'id', 'username'), array('prompt' => 'Select User Account')); ?>
		<?php endif; ?>
		<?php echo $form->error($model,'account_id'); ?>
	</div>
	
	<div class="row">
		<?php echo $form->labelEx($model,'total_cost'); ?>
		<?php echo $form->textField($model,'total_cost',array('id'=>'total_cost','readonly'=>true,)); ?>
		<?php echo $form->error($model,'total_cost'); ?>
	</div>
	
	<div class="row buttons">
		<?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save'); ?>
	</div>

<?php $this->endWidget(); ?>

</div><!-- form -->